<?php
class Control_Group extends QUI_Control_Abstract {
    function render() {
        $user = Helper_Rbac::get('user');
        $roles = $user->roles;
//        $ary = array('name'=>'group_id', 'id'=>'group');
        if(!$ary['name']) $ary['name'] = 'grpup_id';
        if(!$ary['id']) $ary['id'] = 'group';

        if($this->_attrs) $ary = array_merge($ary, $this->_attrs);

        if(isset($this->_attrs['selected'])) {
            if(intval($this->_attrs['selected']) == 0) {
                $selected = array(0);
            }
            else {
                $selected = array($this->_attrs['selected']);
            }
        }
        else {
            $selected = FUNC::setArrayByField(array('role_id'), $roles, false);
        }
//        dump($selected);

        //        dump($roles);
        //        dump(FUNC::setArrayByField(array('role_id'), $roles, false));
        return Role::droplist($ary, $selected);
        //        $this->_view['department_droplist'] = Department::droplist(array('name'=>'depart_id'));
        //        return $this->_fetchView('view:' .Q::ini('appini/front/view/style'). '/_control/department');
    }

}
?>